var alert_danger_template = "<div class='alert alert-danger alert-dismissable fade in'>" +
	                            "<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" +
	                            "TIPS_INFO"+
	                        "</div>";
$(".login_btn").click(function(event){
	event.stopPropagation();
	var ele = this;
	$(ele).attr("disabled","disabled");
	$(".login_btn").text("登陆中...");
	var email = $("#email").val();
	var password = $("#password").val();
	$.ajax({
        type: "POST",
        url: "/ynrfinance/userLogin",
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify({'email':email, 'password':password}),
        dataType: "json",
        success: function (data) {
        	if(!data.success){
        		$(ele).removeAttr("disabled");
            	$(".login_btn").text("登陆");
        		$("#server_tips").html(alert_danger_template.replace('TIPS_INFO', data.info));
        	} else {
        		window.location.href = '/ynrfinance/home';
        	}
        },
        error: function (data) {
        	$(ele).removeAttr("disabled");
        	$(".login_btn").text("登陆");
        	$("#server_tips").html(alert_danger_template.replace('TIPS_INFO', data.info));
        }
    });
	return false;
});